package com.vincent.kdp.js;

import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

import com.vincent.baseapp.util.SPUtil;
import com.vincent.kdp.Activity.QualitypolicyActivity;
import com.vincent.kdp.ui.commodity.repository.CommodityDetailRepository;
import com.vincent.kdp.util.BaseParam;

/**
 * Created by Administrator on 2017/8/11 0011.
 */

public class ReserveOperator {
    private Activity activity;
    private String barCode;
    private CommodityDetailRepository repository=new CommodityDetailRepository();

    public ReserveOperator(Activity activity,String barCode) {
        this.activity = activity;
        System.out.println("oper-----"+barCode);
        this.barCode=barCode;
    }

    @JavascriptInterface
    public String getDeviceId(){
        return BaseParam.getDeviceId();
    }
    @JavascriptInterface
    public String getBarCode(){
        System.out.println("oper-----"+barCode);
        return barCode;
    }


    @JavascriptInterface
    public void getData(final String message){
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Log.i("code",message);
                if("0".equals(message)){
                    activity.finish();
                   Toast.makeText(activity, "添加预定成功", Toast.LENGTH_SHORT).show();
                    //MainActivity.reload=1;
                  //  Intent intent =new Intent(activity, QualitypolicyActivity.class);
                   // intent.putExtra("barCode", barCode);
//                    intent.putExtra("url", url);
                    //activity.startActivity(intent);

                }
            }
        });

    }

}
